package com.zzl.mine.service.system.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zzl.mine.dao.system.RoleMapper;
import com.zzl.mine.pojo.page.PageData;
import com.zzl.mine.pojo.system.Role;
import com.zzl.mine.service.system.RoleService;

/**
 * @description 角色服务接口
 * @author rambo
 * @date 2018年6月7日 下午5:34:37
 */
@Service
public class RoleServiceImpl implements RoleService {

	@Autowired
	private RoleMapper roleMapper;

	/**
	 * @description 列出此组下级角色
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Role> listAllRolesByPId(PageData pd) throws Exception {
		return roleMapper.listAllRolesByPId(pd);
	}

	/**
	 * @description 列出所有角色
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Role> listAllRoles() throws Exception {
		return roleMapper.listAllRoles();
	}
	
	/**
	 * @description 通过id查找
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@Override
	public PageData findObjectById(PageData pd) throws Exception {
		return roleMapper.findObjectById(pd);
	}

	/**
	 * @description 添加
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void add(PageData pd) throws Exception {
		roleMapper.insert(pd);
	}

	/**
	 * @description 保存修改
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void edit(PageData pd) throws Exception {
		roleMapper.edit(pd);
	}

	/**
	 * @description 删除角色
	 * @param ROLE_ID
	 * @throws Exception
	 */
	@Override
	public void deleteRoleById(String ROLE_ID) throws Exception {
		roleMapper.deleteRoleById(ROLE_ID);
	}

	/**
	 * @description 给当前角色附加菜单权限
	 * @param role
	 * @throws Exception
	 */
	@Override
	public void updateRoleRights(Role role) throws Exception {
		roleMapper.updateRoleRights(role);
	}

	/**
	 * @description 通过id查找
	 * @param roleId
	 * @return
	 * @throws Exception
	 */
	@Override
	public Role getRoleById(String ROLE_ID) throws Exception {
		return roleMapper.getRoleById(ROLE_ID);
	}

	/**
	 * @description 给全部子角色加菜单权限
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void setAllRights(PageData pd) throws Exception {
		roleMapper.setAllRights(pd);
	}

	/**
	 * @description 添加增权限
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void saveAddQx(PageData pd) throws Exception {
		roleMapper.addQx(pd);
	}
	
	/**
	 * @description 添加删权限
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void saveDelQx(PageData pd) throws Exception {
		roleMapper.delQx(pd);
	}
	
	/**
	 * @description 添加改权限
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void saveEditQx(PageData pd) throws Exception {
		roleMapper.editQx(pd);
	}
	
	/**
	 * @description 添加查权限
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void saveChaQx(PageData pd) throws Exception {
		roleMapper.chaQx(pd);
	}

}
